﻿
@model Abc.Application.HtAdminServices.HtRoleOut
@{
    ViewData["Title"] = "RoleInfo";
}

<section class="panel panel-padding">
    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">

        <form class="layui-form" action="">
            <input type="hidden" asp-for="Id" />

            <div class="layui-bg-gray" style="padding: 30px;">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md6">
                        <div class="layui-card">
                            <div class="layui-card-header">角色信息</div>
                            <div class="layui-card-body">
                                @*<div class="layui-form-item">
                                     <label class="layui-form-label">标识</label>
                                      <div class="layui-input-block">
                                            <input  asp-for="Code" lay-verify="Code" autocomplete="off" placeholder="请输入标识" class="layui-input">
                                      </div>
                                      <div class="layui-form-mid layui-word-aux">
                                      </div>
                                    </div>*@

                                <div class="layui-form-item">
                                    <label class="layui-form-label">名称</label>
                                    <div class="layui-input-block">
                                        <input asp-for="Name" lay-verify="Name" autocomplete="off" placeholder="请输入名称" class="layui-input">
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">是否启用</label>
                                    <div class="layui-input-block">
                                        @*<input type="checkbox" asp-for="IsEnable" lay-skin="primary" title="" checked="">
                                            <input type="checkbox" name="like[read]" title="阅读" checked="">*@
                                        <input type="checkbox" asp-for="IsEnable" lay-skin="switch" lay-text="开|关">
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">备注</label>
                                    <div class="layui-input-block">
                                        <textarea asp-for="Remark" lay-verify="Remark" autocomplete="off" placeholder="请输入备注" class="layui-textarea"></textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <div class="layui-card">
                            <div class="layui-card-header">权限</div>
                            <div class="layui-card-body">
                                <ul id="selectPermission" class="dtree" data-id=""></ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <div class="layui-btn submitbtn" lay-submit lay-filter="submit">提交数据</div>
                    <div class="layui-btn layui-btn-danger closewindow">关闭窗口</div>
                    <div class="layui-btn layui-btn-danger refreshwindow">重新加载</div>
                </div>
            </div>
        </form>
    </div>
</section>

@*<script src="~/lib/ckeditor4/ckeditor.js"></script>*@
@section Scripts{
    <script>
         layui.define(['element', 'jquery', 'form',  'dtree'], function () {
             let $ = layui.jquery;
             let  form = layui.form;
             let dtree = layui.dtree;

             //Info 初始化
             abc.infoInit();
             //提交
             form.on('submit(submit)', function (obj) {
                 obj.field.IsEnable=$('#IsEnable').is(':checked');
                 //obj.field.Remark = Remark.getContent();

                 var params1 = dtree.getCheckbarNodesParam("selectPermission");

                 var params2 = dtree.getCheckbarJsonArrParam("selectPermission");


                 var params = dtree.getCheckbarNodesParam("selectPermission");
                 var ids = "";
                 $(params).each(function (index, element) {
                     if (element.nodeId.indexOf("m_") == -1) {
                         ids += element.nodeId + ",";
                     }
                 });
                 ids = ids.substr(0, ids.length - 1);
                 obj.field.permissionstrs = ids;
                 abc.post({
                     url: "@(Url.Action("SetMenuPermission"))"
                     , data: obj.field
                 });

                 return false;
             });

             dtree.render({
                elem: "#selectPermission",
                //initLevel: "1",
                method: 'get',
                url: "@Url.Action("GetPermissionDtree")?roleid=@(Model?.Id??0)",
                initLevel: 1,
                checkbar: true,
                menubar: true,
                menubarFun: {
                    group: ["moveDown", "moveUp", "refresh", {
                        menubarId: "extGroupId1",  // 按钮的唯一ID
                        icon: "dtree-icon-homefill", // 从dtreefont库中选取
                        title: "自定义按钮1",  // 按钮的提示标题
                        handler: function (node, $div) {  //扩展按钮的回调函数
                            layer.msg(JSON.stringify(node));
                        }
                    }]
                }
                //checkbarType: "all" // 默认就是all，其他的值为： no-all  p-casc   self  only
              });

         });
    </script>
}
